<template>
    <el-container class="home-container">
        <el-header>
            <div>
                <img src="../assets/logo.png"/>
                <span>后台管理系统</span>
            </div>
            <el-button type="info" @click="logout">退出</el-button>
        </el-header>
        <el-container>
            <el-aside :width="isCollapse ? '64px' : '200px'">
                <div class="toggle-button" @click="toggleClapse">||||</div>
                <el-menu
                        background-color="#333744"
                        text-color="#fff"
                        active-text-color="#ffd04b"
                        router
                        unique-opened
                        :collapse="isCollapse"
                        :collapse-transition="false"
                >
                    <el-submenu :index="item.id + ''" v-for="item in menuList" :key="item.id">
                        <template slot="title">
                            <i class="el-icon-location"></i>
                            <span>{{item.name}}</span>
                        </template>
                        <el-menu-item
                                :index="subMenu.url+''"
                                v-for="subMenu in item.children"
                                :key="subMenu.id"
                        >
                            <template slot="title">
                                <i class="el-icon-location"></i>
                                <span>{{subMenu.name}}</span>
                            </template>
                        </el-menu-item>
                    </el-submenu>
                </el-menu>
            </el-aside>
            <el-main>
                <router-view v-if="isRouterAlive"/>
            </el-main>
        </el-container>
    </el-container>
</template>
<script>
    export default {
        data() {
            return {
                menuList: [
                    {
                        id: 1,
                        name: "系统首页",
                    },
                    {
                        id: 2,
                        name: "运动健康",
                        children: [{id: 3, name: "数据查询", url: "/department"},
                            {id: 4, name: "数据分析", url: "/department"}
                        ]
                    },
                    {
                        id: 5,
                        name: "医疗服务",
                        children: [{id: 6, name: "科室管理", url: "/permission"},
                            {id: 7, name: "医院管理", url: "/permission"},
                            {id: 8, name: "医生管理", url: "/permission"},
                            {id: 9, name: "疾病管理", url: "/permission"},
                            {id: 10, name: "预约设置", url: "/permission"},
                            {id: 11, name: "预约查询", url: "/permission"},
                            {id: 12, name: "挂号订单", url: "/permission"},
                            {id: 13, name: "体检订单", url: "/permission"},
                            {id: 14, name: "问诊订单", url: "/permission"},
                            {id: 15, name: "问诊设置", url: "/permission"},
                            {id: 16, name: "体检报告", url: "/permission"},

                        ]
                    },
                    {
                        id: 17,
                        name: "商城管理",
                        children: [{id: 18, name: "品类管理", url: "/category"},
                            {id: 19, name: "商品管理", url: "/commodity"},
                            {id: 20, name: "订单管理", url: "/order"},
                            {id: 21, name: "售后服务", url: "/aftermarket"},
                            {id: 22, name: "运费模板", url: "/freight"},

                        ]
                    },
                    {
                        id: 23,
                        name: "内容管理",
                        children: [{id: 24, name: "栏目管理", url: "/courseList"},
                            {id: 25, name: "资讯管理", url: "/courseList"},
                            {id: 26, name: "审核列表", url: "/courseList"},
                            {id: 27, name: "广告管理", url: "/courseList"},

                        ]
                    },
                    {
                        id: 28,
                        name: "数据统计",
                        children: [{id: 29, name: "用户统计", url: "/sysrole"},
                            {id: 30, name: "挂号统计", url: "/sysrole"},
                            {id: 31, name: "体检统计", url: "/sysrole"},
                            {id: 32, name: "问诊统计", url: "/sysrole"},
                            {id: 33, name: "销售统计", url: "/sysrole"},

                        ]
                    },
                    {
                        id: 34,
                        name: "系统管理",
                        children: [
                            {id: 35, name: "用户列表", url: "/sysrole"},
                            {id: 36, name: "角色管理", url: "/sysrole"},
                            {id: 37, name: "账号管理", url: "/sysrole"},
                            {id: 38, name: "封禁管理", url: "/sysrole"},
                            {id: 39, name: "操作日志", url: "/sysrole"},


                        ]
                    }
                ],
                isCollapse: false,
                isRouterAlive: true
            };
        },
        methods: {
            reload() {
                this.isRouterAlive = false;
                this.$nextTick(function () {
                    this.isRouterAlive = true;
                });
            },
            toggleClapse() {
                this.isCollapse = !this.isCollapse;
            },
            logout() {
                // window.sessionStorage.clear();
                //  this.$router.push("/login");
            },
            loadMenus() {

            }
        },
        created() {

        }
    };
</script>
<style lang="less" scoped>
    img {
        width: 30px;
        height: 30px;
    }

    .toggle-button {
        background-color: #373d48;
        font-size: 10px;
        text-align: center;
        color: #fff;
        letter-spacing: 0.2em;
        cursor: pointer;
    }

    .el-header {
        background-color: #373d41;
        display: flex;
        justify-content: space-between;
        padding-left: 0;
        align-items: center;
        color: #fff;
        font-size: 22px;

        > div {
            display: flex;
            align-items: center;

            span {
                margin-left: 14px;
            }
        }
    }

    .el-aside {
        background-color: #333744;

        .el-menu {
            border-right: 0;
        }
    }

    .el-main {
        background-color: #eaedf1;
    }

    .home-container {
        height: 100%;
    }
</style>